package com.stylefeng.guns.rest.modular.App.service.impl;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.model.Pager;
import com.stylefeng.guns.rest.modular.App.dao.NoticeInfMapper;
import com.stylefeng.guns.rest.modular.App.model.NoticeInf;
import com.stylefeng.guns.rest.modular.App.service.INoticeInfService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;


/**

 * 通知信息 Service 实现 
 * @author sasazaixian
 * @Date 2018-11-15 16:38
 */
@Service
public class NoticeInfServiceImpl extends ServiceImpl<NoticeInfMapper,NoticeInf> implements INoticeInfService {

    @Resource
    private NoticeInfMapper noticeInfMapper;

    /**
     * 查询通知信息列表
     * @param noticeInf 通知信息对象
     * @return
     */
    public List<NoticeInf> selectListNoticeInf(NoticeInf noticeInf,String token)throws Exception{
        if(noticeInf==null){
            noticeInf=new NoticeInf();
            noticeInf.setNiState("1");
        }
        if(noticeInf.getNiState()==null){
            noticeInf.setNiState("1");
        }
        return  this.noticeInfMapper.selectListNoticeInf(noticeInf);
    }
    /**
	 * 分页查询通知信息列表
     * @param pager 分页对象
     * @return
     */     
    public  Map pageListNoticeInf(Pager pager,String token) throws Exception{
        Page page=new Page(pager.getPageNumber(),pager.getPageSize());
        NoticeInf notice=(NoticeInf)pager.getObj();
        if(notice==null){
            notice=new NoticeInf();
            notice.setNiState("1");
        }
        if(notice.getNiState()==null){
            notice.setNiState("1");
        }
        page.setRecords(noticeInfMapper.selectListNoticeInf(page,notice));
        List<NoticeInf> list = page.getRecords();
        Map mapDate = new HashMap();
        mapDate.put("rows", list);
        mapDate.put("total", page.getTotal());
        mapDate.put("page", page.getCurrent());
        mapDate.put("pageCount", page.getPages());
        return mapDate;
    }
    /**
     * 通过主键id查询的通知信息列表
     * @param id 主键id
     * @return     
     */
    public  NoticeInf findNoticeInfById(String id,String token)throws Exception{
        return  this.noticeInfMapper.findNoticeInfById(id);
    }
}
